﻿using ERP_SaaS_WinForm.销售.Sales;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ERP_SaaS_WinForm.销售
{
    public partial class AddDiscount : Form
    {
        public AddDiscount()
        {
            InitializeComponent();
        }

        private async void AddDiscount_Load(object sender, EventArgs e)
        {
            //Api基础地址
            string baseUrl = "http://localhost:5054/api/Ladder/GetLadder";
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(baseUrl);
                response.EnsureSuccessStatusCode();
                string jsonResponse = await response.Content.ReadAsStringAsync();

                LadderApiResponse apiResponse = JsonConvert.DeserializeObject<LadderApiResponse>(jsonResponse);
                if (apiResponse.code == 200)
                {
                    dgvLadder.DataSource = apiResponse.data;
                    
                }
                else
                {
                    // 显示错误信息
                    MessageBox.Show($"查询失败{apiResponse.msg}");
                }
            }
        }
    }
}
